function Figure_Unit(Folder,SS,IRF)
% load('Result_0_Baseline.mat');
% Folder          =   'TableGraphs\\Baseline\\';
% IRF         =   IRF_Baseline;
% Folder = 'TableGraphs\\Baseline\\';

mkdir(Folder);

% Setup
T_IRF           =   12;
XT              =   0+(0:1:T_IRF)';
List_Shock      =   {'Eps_Eta_M_dom','Eps_Eta_M_ext','Eps_Eta_Y_H','Eps_Eta_p_F',...
                     'Eps_Eta_Z','Eps_Eta_Z_N','Eps_Eta_Z_H'};

%% Aggregate Variables
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
% Graphics
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.18,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);
%--------------------------------------------------------------------------
% Different Figures
%--------------------------------------------------------------------------
% Prices
LabelList   =   {'Real Rate','Nominal Rate','Inflation','Real Exchange Rate'};

TempFun_LP  =   @(S,C, D)GR_Line('Style',S,'Color',MyColor(C, D),'Width',3);
List_LP     =   {TempFun_LP('-','Black', 1);TempFun_LP('--','Black', 0.2);...
                 TempFun_LP(':','Black', 0.6); TempFun_LP('-.','Black', 0.4)};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Rates to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_Pir     =   IRF.(SH).Pir;
    Dev_ir      =   IRF.(SH).ir;
    Dev_rr      =   IRF.(SH).rr_dom;
    Dev_dE      =   IRF.(SH).dE;
    Dev_RealER  =   -IRF.(SH).RelPrice;
    TempIrf     =   [Dev_rr;Dev_ir;Dev_Pir;Dev_RealER]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'Prices_',SH]);
    close(Fig);
end

% Aggregate Demand
LabelList   =   {'Aggregate Consumption','Export'};

TempFun_LP  =   @(S,C,D)GR_Line('Style',S,'Color',MyColor(C, D),'Width',3);
List_LP     =   {TempFun_LP('-','Black', 1);TempFun_LP('--','Black', 0.5)};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Demand to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    
    Dev_C       =   IRF.(SH).C;
    Dev_Export  =   IRF.(SH).Export;
    Dev_NetExportIdx=IRF.(SH).NetExportIdx;
    
    TempIrf     =   [Dev_C;Dev_Export]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggDemand_',SH]);
    close(Fig);
end

% Aggregate Supply
LabelList   =   {'Output, Home Tradable Goods','Output, Non-tradable Goods', ...
                 'Import'};

TempFun_LP  =   @(S,C, D)GR_Line('Style',S,'Color',MyColor(C, D),'Width',3);
List_LP     =   {TempFun_LP('-','Black', 1);TempFun_LP('--','Black', 0.6);...
                 TempFun_LP('-.','Black', 0.4)};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Supply to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    
    Dev_Y       =   IRF.(SH).Y;
    Dev_Y_H     =   IRF.(SH).Y_H;
    Dev_Y_N     =   IRF.(SH).Y_N;
    Dev_Import  =   IRF.(SH).Import;
    TempIrf     =   [Dev_Y_H;Dev_Y_N;Dev_Import]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggSupply_',SH]);
    close(Fig);
end

% Consumption Components
LabelList   =   {'C: Home Tradable Goods',...
                 'C: Foreign Tradable Goods',...
                 'C: Non-tradable Goods'};

TempFun_LP  =   @(S,C, D)GR_Line('Style',S,'Color',MyColor(C, D),'Width',3);
List_LP     =   {TempFun_LP('-','Black', 1);TempFun_LP('--','Black', 0.6);...
                 TempFun_LP('-.','Black', 0.4)};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Consumption to ',SH],fig_size);
    ax          =   fig_SubPlot(1);

    Dev_C_H     =   IRF.(SH).C_H;
    Dev_C_F     =   IRF.(SH).C_F;
    Dev_C_N     =   IRF.(SH).C_N;
    TempIrf     =   [Dev_C_H;Dev_C_F;Dev_C_N]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggConsumption_',SH]);
    close(Fig);
end
%--------------------------------------------------------------------------
% Collect the Key Variables
%--------------------------------------------------------------------------
TempNameList    =   {'C','Export','Import','Net Export',.... % Aggregate Quantities
                     'Pir','ir','ExchangeRate','UIP Deviation','Relative Price',... % Aggregate Prices
                     'Agg Dom Share','Effective Return for Int HH',... % Portfolio Choices
                     'ConsDist: Std','ConsDiff: RI', 'ConsDiff: FI','ConsDiff: NA' ... % Distributional Concequence
                     };
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    irf         =   IRF.(SH);
  
    [~,MaxIdx]  =   max(abs(IRF.(SH).C));
    TempFun     =   @(irf)irf(MaxIdx);
    TempStatData=   [[TempFun(irf.C);TempFun(irf.Export);TempFun(irf.Import);TempFun(irf.NetExportIdx)]*100;....
                     [TempFun(irf.Pir)*4;TempFun(irf.ir)*4;TempFun(irf.ExchangeRate);TempFun(irf.DevUIP)*4;TempFun(irf.RelPrice)]*100;...
                     [TempFun(irf.DomShare_Pos);TempFun(irf.EffReturn_Pos)]*100;...
                     [TempFun(irf.ConsDist.Disp(1,:)); TempFun(irf.C_byRI_N-irf.C_byRI_H); ...
                      TempFun(irf.C_byFI_dom-irf.C_byFI_ext);TempFun(irf.C_byNA_poor-irf.C_byNA_rich) ...
                      ]/abs(TempFun(irf.C)) ...
                     ];
    if ii_Irf==1
        StatDataArray   =   zeros(length(TempNameList),length(List_Shock));
    end
    StatDataArray(:,ii_Irf) ...
                =   TempStatData;
end
IrfStatTable=   array2table(StatDataArray,'RowNames',TempNameList,'VariableNames',List_Shock);

writetable(IrfStatTable,[Folder,'Irf_KeyResults.xlsx'],'WriteRowNames',true);

%--------------------------------------------------------------------------
% Key Price Differential: Wage
%--------------------------------------------------------------------------
LabelList   =   {'H-Wage','N-Wage'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Blue');TempFun_LP('--','Red')};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Wages to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_W_H     =   IRF.(SH).w_H;
    Dev_W_N     =   IRF.(SH).w_N;
    TempIrf     =   [Dev_W_H;Dev_W_N]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'PriceDiff_Wage_',SH]);
    close(Fig);
end

%--------------------------------------------------------------------------
% Key Price Differential: Return Rate
%--------------------------------------------------------------------------
LabelList   =   {'Expected Return: Domestic Bond','Expected Return: External Bond'};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Expected Return to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_ir_dom  =   IRF.(SH).ir_dom;
    Dev_ir_ext  =   IRF.(SH).ir_ext+[IRF.(SH).dE(2:end),0];
    TempIrf     =   [Dev_ir_dom;Dev_ir_ext]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'PriceDiff_ExpRet_',SH]);
    close(Fig);
end


%% Consumption Difference
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[0.75,1]*1/3; 
fig_gap     =   [0.05,0.08];
fig_VMargin =   [0.10,0.06];
fig_HMargin =   [0.20,0.04]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);

LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Blue'); TempFun_LP('--','Red')};
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
 
    %----------------------------------------------------------------------
    % By Different Characteristics
    %----------------------------------------------------------------------
    Dev_AggStat =   IRF.(SH).AggStat./SS.AggStat;
    Dev_AggStat(abs(Dev_AggStat)<1e-5)  =   0;
    Scale       =   [min(min(Dev_AggStat(1:6,:)));max(max(Dev_AggStat(1:6,:)))]*100;
    % Real Integration
    Fig         =   FigureSetup(['By Real, Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(4,:);Dev_AggStat(3,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Integrated','Nonintegrated'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByRI_',SH]);
    close(Fig);
    
    % Financial Integration
    Fig         =   FigureSetup(['By Fin., Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(2,:);Dev_AggStat(1,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Integrated','Nonintegrated'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByFI_',SH]);
    close(Fig);
    
    % Rich vs. Poor
    Fig         =   FigureSetup(['By Asset, Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(6,:);Dev_AggStat(5,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'High Net Asset','Low Net Asset'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByNA_',SH]);
    close(Fig);
end

%% Distribution of Consumption 
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2f'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempFun_LP  =   @(S,C, D)GR_Line('Style',S,'Color',MyColor(C, D),'Width',3);
List_LP     =   {TempFun_LP('-','Black', 1);TempFun_LP('--','Black', 0.6);...
                 TempFun_LP('-.','Black', 0.4)};
             
SummaryStat =    {'std','p75-p25','p90-p10','std, normalized','p75-p25, normalized','p90-p10, normalized','RI','FI','NA'};
SummaryTable=   zeros(length(SummaryStat),length(List_Shock));
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   TempFun_MaxC(IRF.(SH).C);
    ConsDist    =   IRF.(SH).ConsDist;
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Disp(1,:);ConsDist.Disp(3,:);ConsDist.Disp(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1)*100;
    LabelList   =   {'std','p75-p25','p90-p10'};
    
    Fig         =   FigureSetup(['Deviation Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Level_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Dispersion: Normalized
    %----------------------------------------------------------------------
    TempIrf     =   TempIrf/(MaxAbsC_Val*100);
    
    Fig         =   FigureSetup(['Deviation Dispersion: Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Normalized_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Gini and Top Shares
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Gini;ConsDist.TopShare(1,:);ConsDist.TopShare(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Gini','Top Share: 10\%','Top Share: 90\%'};
        
    Fig         =   FigureSetup(['Level Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_LevelDisp_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Variance Decomposition
    %----------------------------------------------------------------------
    TempIrfList =   {'RI','FI','NA','RI_FI','RI_NA','FI_NA','RI_FI_NA','NA_Fine','z'};
    TempIrf     =   zeros(length(TempIrfList),size(ConsDist.VarDec.RI,2));
    for jj=1:length(TempIrfList)
        TempIrf(jj,:)   =   ConsDist.VarDec.(TempIrfList{jj})(1,:);
    end
    TempIrf     =   TempIrf(:,MaxAbsC_Idx);
    TempTable   =   array2table(round(TempIrf,3),'VariableNames',{'WithinGroup'},...
                                                 'RowNames',TempIrfList);
    writetable(TempTable,[Folder,'Irf_VarDec.xlsx'],'WriteRowNames',true,'Sheet',SH);
    %----------------------------------------------------------------------
    % Summary Table
    %----------------------------------------------------------------------
    
    TempIrf_1   =   [ConsDist.Disp(1,:);ConsDist.Disp(3,:);ConsDist.Disp(2,:)];
    TempIrf_2   =   [ConsDist.VarDec.RI(2,:);ConsDist.VarDec.FI(2,:);ConsDist.VarDec.NA_Fine(2,:)];
    TempIrf     =   [TempIrf_1(:,MaxAbsC_Idx);...
                     TempIrf_1(:,MaxAbsC_Idx)/MaxAbsC_Val;...
                     TempIrf_2(:,MaxAbsC_Idx)];
    
    SummaryTable(:,ii_Irf) ...
                =   TempIrf;
end
SummaryTable    =   array2table(SummaryTable, ...
                                'VariableNames',List_Shock,...
                                'RowNames',SummaryStat);
writetable(SummaryTable,[Folder,'ConsDispSummary.xlsx'],'WriteRowNames',true);

%% Appendix
TempDict    =   @(L,S)struct('Scale',S,'Label',L);
VarDict     =   struct('C',TempDict('Consumption',1e2), ...
                       'C_N',TempDict('Consumption: N',1e2),...
                       'C_H',TempDict('Consumption: H',1e2),...
                       'C_F',TempDict('Consumption: F',1e2),...
                       'L_N',TempDict('Hours: N',1e2),'L_H',TempDict('Hours: H',1e2),...
                       'w_N',TempDict('Real wage: N',1e2),'w_H',TempDict('Real wage: H',1e2),...
                       'Y_N',TempDict('Output: N',1e2),'Y_H',TempDict('Output: H',1e2),...
                       'ir',TempDict('Domestic nominal rate',1e2*4),'dE',TempDict('Depreciation',1e2*4),...
                       'Pir',TempDict('Inflation',1e2*4), 'Pir_N',TempDict('Inflation: N',1e2*4), ... 
                       'Pir_H',TempDict('Inflation: H',1e2*4), 'Pir_F',TempDict('Inflation: F',1e2*4), ...
                       'DevUIP',TempDict('UIP deviation',1e2*4),'RelPrice',TempDict('Relative price',10e2),...
                       'DomShare_Pos', TempDict('Domestic share: saver ($\alpha^{+}$)',1e2), 'DomShare_Neg', TempDict('Domestic share: borrower ($\alpha^{-}$)',1e2),...
                       'AggDomesticAsset', TempDict('Private domestic bond holdings ($q_{Dt}B_{ss}$)',10e2),...
                       'AggForeignAsset', TempDict('Private external bond holdings',1e2), ...
                       'CurAccIdx', TempDict('Current Account/Output',10e2),'RealER',TempDict('Real exchange rate',10e2) ...
                       );

               
VarList     =   fieldnames(VarDict);

% Graph
Num_Var     =   length(VarList);
Num_Shock   =   length(List_Shock);

N_col       =   4;
N_row       =   ceil(Num_Var/N_col);
fig_size    =   [N_col,N_row].*[1,0.75]*1/4;  
fig_gap     =   [0.04,0.04];
fig_VMargin =   [0.03,0.03];
fig_HMargin =   [0.04,0.01]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
                                 
AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',6,'Y',6),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',1,'MinUnit',0.01).Setup(Y);

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black')};
             
for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    fig_Handle  =   FigureSetup(['IRF-',SH],fig_size);
    for ii_vv=1:Num_Var
        VV              =   VarList{ii_vv};
        ax              =   fig_SubPlot(ii_vv);
        if strcmp(VV,'dE_Real')
            TempIrf         =   IRF.(SH).dE-IRF.(SH).Pir;
        elseif strcmp(VV,'E')
            TempIrf         =   cumsum(IRF.(SH).dE);
        elseif strcmp(VV,'CPI')
            TempIrf         =   cumsum(IRF.(SH).Pir);
        elseif strcmp(VV,'RealER')
            TempIrf         =   -IRF.(SH).RelPrice;
        else
            TempIrf         =   IRF.(SH).(VV);
        end
        TempIrf(abs(TempIrf)<1e-6)  =   0;
        TempIrf     =   TempIrf*VarDict.(VV).Scale;
       % AxisSetup.Exponent  =   struct('X',0,'Y',floor(log(max(max(abs(TempIrf(:))),1e-7))/log(10)));
        [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                 'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                 'AxisProperty',AxisSetup,'Symmetric',1);
        title(VarDict.(VV).Label,'fontsize',8,'interpreter','latex');

    end

    print(fig_Handle,[Folder,'Full_',SH],'-depsc'); 
    close(fig_Handle);
end

%% Distributional Effects
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1.05,0.80]*1/2.5; 

AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
LineStyle   =   {'-','--','-.';'b','r','m';2,2,2};
%--------------------------------------------------------------------------
% Webplot, by FI x RI
%--------------------------------------------------------------------------
fig_gap     =   [0.00,0.00];
fig_VMargin =   [0.00,0.00];
fig_HMargin =   [0.00,0.00]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);

LEG         =   @(LabelList)legend(LabelList,'fontsize',AxFontSize,'interpreter','latex',...
                                                'location','southoutside','Orientation','Vertical');

% Separated
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    % Normalized
    Fig         =   FigureSetup(['Web Plot, Distributional Effect by FI x RI, Normalized'],fig_size);
    ax          =   fig_SubPlot(1);
    TempFun_WebPlot({IRF.(SH)});
%     LEG('Benchmark');
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByFIxRI_',SH]);
    close(Fig);
    
    Fig         =   FigureSetup(['Web Plot, Distributional Effect by FI x RI, Normalized, Simplified'],fig_size);
    ax          =   fig_SubPlot(1);
    TempFun_WebPlot_4Dim({IRF.(SH)});
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByFIxRI_Simplified_',SH]);
    close(Fig);
end

%--------------------------------------------------------------------------
% Line-plot, by NA
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.05]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2f'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',1).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempLine    =   GR_Line('Style','-','Color',MyColor('Blue'),'Width',3);
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   TempFun_MaxC(IRF.(SH).C);
    ConsDist    =   IRF.(SH).ConsDist;
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   ConsDist.AvgDev_byNA(:,MaxAbsC_Idx)'/MaxAbsC_Val;
    
    Fig         =   FigureSetup(['Line Plot, Distributional Effect by NA, Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    XAxis       =   (1:1:size(ConsDist.AvgDev_byNA,1))';
    PH          =   TempLine.Plot(ax,XAxis,TempIrf);
    ax.YTick    =   Tick_Y(TempIrf);
    ax.XTick    =   XAxis;
    hline       = refline(0,1); 
    hline.Color = MyColor('Black');
    ax.XLim     =   [min(XAxis),max(XAxis)];
    ax.XTickLabel=  {'$\leq Q_{20}$', '$(Q_{20},Q_{40}]$', '$(Q_{40},Q_{60}]$', '$(Q_{60},Q_{80}]$', '$>Q_{80}$'};
    ax.TickLabelInterpreter = 'latex';
    XLabel('Net Wealth'); YLabel('Average Consumption Response');
    AxisSetup.Setup(ax);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByNA_',SH]);
    close(Fig);
end
